﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>删除表格指定行</title>
    <script type="text/javascript">
        function deleteRow(tableID,rowIndex){
            var table = document.all[tableID];  // 获得当前表格
            table.deleteRow(rowIndex);  // 通过行索引删除行
        }
    </script>
</head>
<body>
<table id=mytable border=1>
    <tr>
        <td>第1行</td><td onclick="deleteRow('mytable',this.parentElement.rowIndex)">删除当前行</td>
    </tr>
    <tr>
        <td>第2行</td><td onclick="deleteRow('mytable',this.parentElement.rowIndex)">删除当前行</td>
    </tr>
    <tr>
        <td>第3行</td><td onclick="deleteRow('mytable',this.parentElement.rowIndex)">删除当前行</td>
    </tr>
    <tr>
        <td>第4行</td><td onclick="deleteRow('mytable',this.parentElement.rowIndex)">删除当前行</td>
    </tr>
</table>
</body>
</html>